#include<iostream>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>

using namespace std;

int main()
{
    pid_t id = fork();
    if(id == 0)  // 子进程
    {
        sleep(3);
        execl("/bin/ls","ls","-a","-l",nullptr);
        exit(1);
    }
    // 父进程
    pid_t rid = waitpid(id,nullptr,0);
    if(rid > 0)
    {
        cout << "等待子进程成功！" << endl;
    }
    return 0;
}
